#pragma once


#include "BasicObject.h"
#include "typdefs.h"
#include "Emotion.h"

#include <string>
#include <map>
#include "personalitytraitmotivational.h"
#include "functions.h"

namespace BAA
{

	class PersonalityTraitMotivational;
	typedef std::map<std::string, PersonalityTraitMotivational*, std::less<std::string>>  StringPersonalityMap;


	typedef std::map<std::string, FunctionP2*, std::less<std::string>> StringFunctionP2Map;
	typedef std::map<std::string, Function*, std::less<std::string>> StringFunctionMap;

	class TemplateFactory
	{
	public:
		TemplateFactory()
		{

		}

		~TemplateFactory()
		{

		}

		inline void AddFunctionP2ToFactory(std::string name, FunctionP2 * function)
		{
			mFunctionP2[name] = function;
		}

		inline FunctionP2* GetFunctionP2(std::string name)
		{
			return mFunctionP2[name];
		}

		inline void AddFunctionToFactory(std::string name, Function * function)
		{
			mFunction[name] = function;
		}

		inline Function* GetFunction(std::string name)
		{
			return mFunction[name];
		}

		inline void AddPersonalityTraitsToFactory(std::string name, PersonalityTraitMotivational * personalityTrait)
		{
			mPersonalities[name] = personalityTrait;
		}

		inline PersonalityTraitMotivational * BuildPersonality(std::string name)
		{
			PersonalityTraitMotivational* personalityToCopy = mPersonalities[name];

			if(personalityToCopy == NULL)
			{
				return NULL;
			}
			else
			{
				return new PersonalityTraitMotivational(name);
			}
		}

		inline void AddEmotionToFactory(std::string name, Emotion * emotion)
		{
			mEmotions[name] = emotion;
		}


		inline Emotion * BuildBasicEmotion(std::string name)
		{
			// function pointers remain the same. 
			// create a new emotion object
			// associate function and return

			Emotion * emotionToCopy = mEmotions[name];

			if(emotionToCopy == NULL)
				return NULL;
			else
			{
				return emotionToCopy->Copy();
			}


		}


	private:
		StringEmotionMap mEmotions;
		StringPersonalityMap mPersonalities;
		StringFunctionP2Map mFunctionP2;
		StringFunctionMap mFunction;
		

	};// end class



}// end namespace
